<!doctype html>
<html>
<head>
<meta charset="utf-8"/>
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-touch-fullscreen" content="yes">
<title>S.ready Test</title>
</head>
<body>

<script src="/kissy/build/seed.js"></script>

<div id="out" style="margin: 20px"></div>
<script>
    var S = KISSY,
        get = function(id) {
            return document.getElementById(id);
        },
        log = function(msg) {
            out.innerHTML += msg + '<br>';
        },
        out = get('out'),
        readyTime, loadTime;

    S.ready(function() {
        readyTime = S.now();
        S.log('readyTime = ' + readyTime);
    });

    window.onload = function() {
        loadTime = S.now();
        S.log('loadTime = ' + loadTime);
        test();
    };

    function test() {
        var diff = loadTime - readyTime;
        log((diff < 0 ? '[FAILED] ' : '[PASSED] ') + 'loadTime - readyTime = ' + diff + 'ms');

        var ifr = get('test-iframe');
        diff = ifr.contentWindow.loadTime - ifr.contentWindow.readyTime;
        log((diff < 0 ? '[FAILED] ' : '[PASSED] ') + 'iframe loadTime - readyTime = ' + diff + 'ms');
    }
</script>

<iframe id="test-iframe" src="iframe.html"></iframe>
<iframe src="slow-iframe.jss"></iframe>
</body>
</html>
